package com.java.dao.impl;

import com.java.dao.PayInfoAllDao;
import com.java.domain.PayInfoAll;
import com.java.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * @version 2020.3.4
 * @User 悠恋
 * @Data 2022/11/26
 * @Time 20:54
 */
public class PayInfoAllDaoImpl implements PayInfoAllDao {
    private QueryRunner qr = new QueryRunner(DruidUtils.dataSource);
    String sql = "";

    @Override
    public int savePayInfo(PayInfoAll payInfoAll) {
        try {
            // 编写sql
            sql = "INSERT INTO payinfoall(porder,pordername,ptotal) values (?,?,?)";
            // 准备数据
            Object[] params = {payInfoAll.getPorder(), payInfoAll.getPordername(), payInfoAll.getPtotal()};
            // 执行sql 返回结果
            return qr.update(sql, params);
        } catch (SQLException e) {
            e.printStackTrace();
            return 0;

        }

    }
}
